﻿using System.Data;
using System.Data.SqlClient;
using KnowledgeNotebook.BaseClass;

namespace KnowledgeNotebook.BLL
{
    public class GetParameters:DatabaseOptionBaseClass,INotebook
    {
        public SqlParameter[] GetInsertParameters(string title, string detail)
        {
            SqlParameter[] sqlParameter=new SqlParameter[]
                                        {
                                            new SqlParameter("@Title",SqlDbType.VarChar,50), 
                                            new SqlParameter("@Detail",SqlDbType.NText), 
                                        };
            sqlParameter[0].Value = title;
            sqlParameter[1].Value = detail;
            
            return sqlParameter;

        }

        public SqlParameter[] GetDeleteParameters(int id)
        {
            SqlParameter[] sqlParameters=new SqlParameter[]
                                             {
                                                 new SqlParameter("@ID",SqlDbType.BigInt),
                                             };
            sqlParameters[0].Value = id;
            return sqlParameters;
        }

        public SqlParameter[] GetSearchParameters(string title)
        {
            SqlParameter[] sqlParameters=new SqlParameter[]{new SqlParameter("@Title",SqlDbType.VarChar,50), };
            sqlParameters[0].Value = title;
            return sqlParameters;
        }

        public SqlParameter[] GetUpdateParameters(int id,string title,string detail)
        {
            SqlParameter[] sqlParameter = new SqlParameter[]
                                        {
                                            new SqlParameter("@ID",SqlDbType.BigInt), 
                                            new SqlParameter("@Title",SqlDbType.VarChar,50), 
                                            new SqlParameter("@Detail",SqlDbType.NText), 
                                        };
            sqlParameter[0].Value = id;
            sqlParameter[1].Value = title;
            sqlParameter[2].Value = detail;
            return sqlParameter;
        }
    }
}
